package cn.com.nes.site.entity.em;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 工单紧急程度
 */
public enum WorkOrderEmergencyDegreeEnum {

    _0("0", "非常紧急"),

    _1("1", "一般紧急"),

    _2("2", "不紧急"),
    ;

    private String key;
    private String val;

    WorkOrderEmergencyDegreeEnum(String key, String val){
        this.key = key;
        this.val = val;
    }

    public String getVal() {
        return val;
    }

    public String getKey(){
        return key;
    }

    public static String getVal(Integer key) {
        if (ObjectUtil.isNull(key)) return StrUtil.EMPTY;
        Map<String, String> map = Arrays.stream(values())
                .collect(Collectors.toMap(WorkOrderEmergencyDegreeEnum::getKey, WorkOrderEmergencyDegreeEnum::getVal));
        return map.get(String.valueOf(key));
    }

    public static List<Map<String, Object>> getListMap() {
        List<Map<String, Object>> list = new ArrayList<>();
        for (WorkOrderEmergencyDegreeEnum item : values()) {
            Map<String, Object> map = new HashMap<>();
            map.put("key", item.getKey());
            map.put("value", item.getVal());
            list.add(map);
        }
        return list;
    }

}
